package model

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Phone    string `gorm:"type:char(11)" json:"phone"`
	Password string `gorm:"type:varchar(32)" json:"password"`
	Username string `gorm:"type:varchar(20)" json:"username"`
	Image    string `gorm:"type:varchar(225)" json:"image"`
}

func (u *User) Adduser(db *gorm.DB) error {
	return db.Debug().Create(&u).Error
}

func (u *User) VeryPhone(db *gorm.DB, phone string) error {
	return db.Debug().Where("phone =?", phone).First(&u).Error
}

func (u *User) QueryUser(db *gorm.DB, userId int) error {
	return db.Debug().Where("id=?", userId).Find(&u).Error
}
